import { VitePWA } from 'vite-plugin-pwa';
import type { PluginOption } from 'vite';

/**
 * 注册PWA应用
 */
export function useVitePWA(): PluginOption {
  return VitePWA({
    includeAssets: ['fonts/*.woff2', 'images/favicon.png', 'images/apple-touch-icon.png'],
    manifest: {
      name: '袋鼠短剧',
      short_name: '袋鼠短剧',
      description: '袋鼠短剧的管理平台',
      background_color: '#f5faff',
      theme_color: '#ffffff',
      related_applications: [
        { platform: 'chrome_web_store', url: './manifest.webmanifest' },
        { platform: 'play', url: './manifest.webmanifest' },
        { platform: 'itunes', url: './manifest.webmanifest' },
        { platform: 'windows', url: './manifest.webmanifest' },
      ],
      icons: [
        { src: './images/pwa_logo_192.png', sizes: '192x192', type: 'image/png' }, // ./表示public文件夹
        { src: './images/pwa_logo_512.png', sizes: '512x512', type: 'image/png' },
        { src: './images/pwa_logo_512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
        { src: './images/pwa_logo_512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
      ],
    },
  });
}
